<!DOCTYPE html>
<html>
<head>
    <title>上传IPA应用</title>
    <style>
        body { font-family: Arial, sans-serif; max-width: 800px; margin: 0 auto; padding: 20px; }
        .form-group { margin-bottom: 15px; }
        label { display: block; margin-bottom: 5px; font-weight: bold; }
        input[type="text"], textarea, select {
            width: 100%;
            padding: 8px;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
        }
        .required:after { content: "*"; color: red; margin-left: 4px; }
        .error { color: red; font-size: 0.9em; margin-top: 5px; }
        button { 
            background-color: #4CAF50;
            color: white;
            padding: 12px 20px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
        }
        .btn-back { 
            background-color: #4CAF50;
            color: white;
            padding: 5px 5px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }
        #td {
        #td {
          border:1px solid #98bf21;
        }
        button:hover { background-color: #45a049; }
    </style>
</head>
<body>
  <h1>上传IPA应用</h1>
  <form id="uploadForm" action="/upload" method="post" enctype="multipart/form-data">
    <!-- 文件上传 -->
    <input type="hidden" name="ipaId" value="{{.AppInfo.ID}}"/>
    <table style="width:600px;">
      <tbody>
        <tr>
	<td><a class="btn-back" href="/">回列表页</a></td>
          <td class="error" id="fileError" colspan="2">{{.ErrMsg}}</td></tr>
        <tr>
          <td class="form-group"><label class="required">IPA文件</label></td>
          <td><input type="file" name="ipaFile" accept=".ipa" required></td>
        </tr>
       <!-- 应用信息 -->
        <tr>
          <td class="form-group"><label>Bundle ID</label></td>
          <td><label>{{.AppInfo.BundleID}}</label></td>
        </tr>
        <tr>
          <td class="form-group"><label>版本号</label></td>
          <td><label>{{.AppInfo.BundleVersion}}</label></td>
        </tr>
        <tr>
          <td class="form-group"><label class="required">版本标签</label></td>
          <td><input style="width:140px;" type="text" name="bundleTag" placeholder="如：1.0.0-prod" value="{{.AppInfo.BundleTag}}" required>
	    <label style="display:inline;">相同BundleID和标签的会覆盖</label>
	  </td>
        </tr>
        <tr>
          <td class="form-group"><label class="required">应用名称</label></td>
          <td><input type="text" name="title" placeholder="应用显示名称" value="{{.AppInfo.Title}}" required></td>
        </tr>
        <tr>
          <td class="form-group"><label class="required">应用类型</label></td>
          <td>
            <select name="kind">
              <option value="software">普通应用</option>
              <option value="enterprise">企业应用</option>
            </select>
          </td>
        </tr>
        <tr>
          <td class="form-group"><label>更新说明</label></td>
          <td><textarea name="updateInfo" rows="4" placeholder="本次更新的主要内容...">{{.AppInfo.UpdateInfo}}</textarea></td>
        </tr>
        <tr>
          <td class="form-group" colspan="2"><button type="submit">提交上传</button></td>
        </tr>
      </tbody>
    </table>
  </form>
  <script>
      document.getElementById('uploadForm').addEventListener('submit', function(e) {
          // 文件类型验证
          const fileInput = document.querySelector('input[name="ipaFile"]');
          if (fileInput.files.length > 0) {
              const fileName = fileInput.files[0].name.toLowerCase();
              if (!fileName.endsWith('.ipa')) {
                  document.getElementById('fileError').textContent = '仅支持.ipa格式文件';
                  e.preventDefault();
              }
          }
      });
  </script>
</body>
</html>
